package com.gxa.order.service.impl;/*
 *Created by${妄也} on 2022/10/7
 */

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.gxa.common.commons.R;
import com.gxa.order.mapper.RefundMapper;
import com.gxa.order.pojo.Refund;
import com.gxa.order.service.RefundService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;

@Service
public class RefundServiceImpl implements RefundService {
@Autowired(required = false)
private RefundMapper refundMapper;
    @Override
    public R addrefund(Refund refund) {
        TimeZone timeZone = TimeZone.getTimeZone("GMT+8");
        TimeZone.setDefault(timeZone);

        //获取当前时间
        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = simpleDateFormat.format(date);
        refund.setRefundTime(format);
        int insert = refundMapper.insert(refund);

        R r = new R();
        r.setCode(200);
        r.setMsg("增加成功");
        return r;
    }

    @Override
    public R findorderid(String order) {
        UpdateWrapper updateWrapper = new UpdateWrapper();
        updateWrapper.eq("hotelorder_id",order);
        Refund refund = refundMapper.selectOne(updateWrapper);
        R r = new R();
        r.setCode(200);
        r.setMsg("查询成功");
        r.setData(refund);
        return r;
    }

}
